﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using HammerMUD.System;
using HammerMUD.Rooms;

namespace HammerMUD.Commands
{
    public class CommandUtilities
    {
        public static void ProcessCommand(String line, User user)
        {
            List<String> arguments = line.Split(new char[] { ' ' }).ToList<String>();
            Boolean success = false;

            if(arguments.Count == 0)
            {
                return;
            }

            foreach (Command c in HammerMUD.System.HammerMUD.Commands)
            {
                if (c.Name.ToLower().Equals(arguments[0].ToLower()) 
                    && c.SecurityLevel <= user.UserAccount.CurrentCharacter.SecurityLevel)
                {
                    c.Do(user, arguments);
                    success = true;
                    break;
                }
            }

            if (!success)
            {
                success = Exit.ParseExit(arguments, user);
            }

            user.UserAccount.StandardPrompt();
        }
    }
}
